package com.xiaoyu.base.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import com.xiaoyu.base.entity.StickerEntity;

import java.util.List;

import static androidx.room.OnConflictStrategy.REPLACE;

@Dao
public interface StickerDao {

    @Insert(onConflict = REPLACE)
    void upsert(StickerEntity entity);

    @Insert(onConflict = REPLACE)
    void upsertList(List<StickerEntity> entityList);

    @Query("DELETE FROM sticker WHERE uid = :uid AND stickerId = :stickerId")
    void delete(String uid, long stickerId);

    @Query("DELETE FROM sticker WHERE uid = :uid AND stickerId IN (:stickerIdList)")
    void deleteList(String uid, List<Long> stickerIdList);

    @Query("DELETE FROM sticker WHERE uid = :uid")
    void deleteAllByUid(String uid);

    @Query("SELECT * FROM sticker WHERE uid = :uid ORDER BY ord ASC, stickerId ASC")
    List<StickerEntity> getStickerEntityList(String uid);
}
